package com.heima.wemedia.common;

import com.heima.model.enums.AppHttpCodeEnum;
import com.heima.utils.common.WmThreadLocal;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;

/**
 * @author 张一恒
 * @version 1.0
 * @description:
 * @date 2023/1/11 21:12
 */
@Slf4j
public class GetUserId {


    public static Integer getUserId() {
        //获取用户id
        Integer userId = WmThreadLocal.getUser().getId();
        if (StringUtils.isEmpty(userId)) {
            log.debug("自媒体接口upload_picture 获取用户id出错：{}", userId);
            throw new RuntimeException(AppHttpCodeEnum.AP_USER_DATA_NOT_EXIST + "");
        }

        return userId;
    }

}
